package com.seeyon.apps.kk.listener;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.collaboration.event.CollaborationFinishEvent;
import com.seeyon.apps.collaboration.po.ColSummary;
import com.seeyon.apps.kk.manager.LockEaPricesManager;
import com.seeyon.apps.kk.manager.LockEaPricesMoreManager;
import com.seeyon.ctp.common.po.template.CtpTemplate;
import com.seeyon.ctp.util.annotation.ListenEvent;
import com.seeyon.kk.utils.ValueUtils;

public class LockEaProcesMoreListener extends BaseListener{
	 private static final Log log = LogFactory.getLog(LockEaProcesMoreListener.class);
	 private LockEaPricesMoreManager lepmmger;
	  
	 public LockEaPricesMoreManager getLepmmger() {
		return lepmmger;
	}
	public void setLepmmger(LockEaPricesMoreManager lepmmger) {
		this.lepmmger = lepmmger;
	}

	@ListenEvent(event=CollaborationFinishEvent.class, async=true)
	  public void oneStart(CollaborationFinishEvent event) throws Exception {
	    Thread.sleep(BaseListener.LISTENER_THREAD_SLEEPTIME);

	    String templetSubject = ValueUtils.getConfig().getString("kk.LockEaPricesMoreListener");

	    ColSummary summary = this.colManager.getColSummaryById(event.getSummaryId());
	    CtpTemplate template = this.templateManager.getCtpTemplate(summary.getTempleteId());
	    String[] templetSubjects = StringUtils.split(templetSubject, ",");

	    if (ArrayUtils.contains(templetSubjects, template.getTempleteNumber())) {
	      Long id = summary.getFormRecordid();
	      this.lepmmger.addEaPricesMoreForm(id);
	    }
	  }
}
